package com.zhifa.redirect.controller;

import com.zhifa.redirect.vo.BodyVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/redirect/test")
@Slf4j
public class RedirectController {



    @GetMapping("/list")
    public Object list(HttpServletRequest request, HttpServletResponse response){

        Map<String, Object> result = new HashMap<>();
        result.put("a", 1);
        result.put("b", 2);
        result.put("c", 3);
        result.put("redirect", "redirect");
        return result;
    }
    @GetMapping("/list1")
    public Object list1(HttpServletRequest request, HttpServletResponse response){

        Map<String, Object> result = new HashMap<>();
        result.put("a", 1);
        result.put("b", 2);
        result.put("c", 3);
        result.put("d", 4);
        return result;
    }

    @PostMapping("/save")
    public Object save(HttpServletRequest request, HttpServletResponse response) {

        return request.getParameterMap();
    }

    @PostMapping("/body")
    public Object body(HttpServletRequest request, HttpServletResponse response, @RequestBody BodyVo bodyVo) {
        log.info("BodyVo:{}",bodyVo);
        return bodyVo;
    }




}
